<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <!--360浏览器优先以webkit内核解析-->
    <title>主页</title>
    <link href="favicon.ico" rel="shortcut icon">
    <link href="../static/css/bootstrap.min.css" rel="stylesheet" th:href="@{/css/bootstrap.min.css}"/>
    <link href="../static/css/font-awesome.min.css" rel="stylesheet" th:href="@{/css/font-awesome.min.css}"/>
    <link href="../static/css/main/animate.min.css" rel="stylesheet" th:href="@{/css/main/animate.min.css}"/>
    <link href="../static/css/main/style.min862f.css" rel="stylesheet" th:href="@{/css/main/style.min862f.css}"/>
</head>

<body class="gray-bg">
<div class="row  border-bottom white-bg dashboard-header">
    <div class="col-sm-12">
                    <h1><strong>路漫漫其修远兮，吾将上下而求索。</strong></h1>
                    <h2><strong>高校实训实习管理系统</strong></h2>
                    <h3><strong>三峡大学计算机与信息学院</strong></h3>
    </div>
    <div class="col-sm-12">
        <div class="col-sm-6">
            <div id="member_chart" style="width: 500px;height: 300px;"></div>
        </div>
        <div class="col-sm-6">
            <div id="project_chart" style="width: 500px;height: 300px;"></div>
        </div>
    </div>

</div>
<script th:src="@{/js/echarts.js}"></script>
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
</body>
<script type="text/javascript">
    // Member Chart
    var dom = document.getElementById('member_chart');
    var myChart = echarts.init(dom, null, {
        renderer: 'canvas',
        useDirtyRect: false
    });
    var app = {};

    var option;

    option = {
        legend: {
            top: 'bottom'
        },
        toolbox: {
            show: true,
            feature: {
                mark: { show: true },
                dataView: { show: true, readOnly: false },
                restore: { show: true },
                saveAsImage: { show: true }
            }
        },
        series: [
            {
                name: '项目成员',
                type: 'pie',
                radius: [50, 100],
                center: ['50%', '50%'],
                roseType: 'area',
                itemStyle: {
                    borderRadius: 8
                },
                data: [
                    { value: 20, name: '吴波' },
                    { value: 20, name: '孙可宇' },
                    { value: 20, name: '吕翀' },
                    { value: 20, name: '王梦帆' },
                    { value: 20, name: '朱专专' },
                ]
            }
        ]
    };

    if (option && typeof option === 'object') {
        myChart.setOption(option);
    }

    window.addEventListener('resize', myChart.resize);

    // Project Chart

    var numbers = [];

    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('project_chart'));

    $.ajax({
        type: "post",
        async: false,
        url: "http://localhost:8080/sau/work/selectWork",
        data: {},
        dataType: "json",
        error: function (errorMessage) {
            alert(errorMessage);
        },
        success: function (result) {
            numbers[0] = result.rows.length
        }
    })

    $.ajax({
        type: "post",
        async: false,
        url: "http://localhost:8080/sau/production/selectProduction",
        data: {},
        dataType: "json",
        error: function (errorMessage) {
            alert(errorMessage);
        },
        success: function (result) {
            numbers[1] = result.rows.length
        }
    })

    // 指定图表的配置项和数据
    var option = {
        title: {
            text: '实训项目'
        },
        tooltip: {},
        legend: {
            data: ['数量']
        },
        xAxis: {
            data: ['学校实训', '企业实训']
        },
        yAxis: {},
        series: [
            {
                name: '数量',
                type: 'bar',
                data: [
                    {
                        value:numbers[0],
                        itemStyle: {
                            barBorderRadius: 5,
                            borderWidth: 1,
                            borderType: 'solid',
                            borderColor: '#73c0de',
                            shadowColor: '#5470c6',
                            shadowBlur: 3
                        }
                    },
                    {
                        value:numbers[1],
                        itemStyle: {
                            barBorderRadius: 5,
                            borderWidth: 1,
                            borderType: 'solid',
                            color: '#76a35c',
                            shadowColor: '#beffa2',
                            shadowBlur: 3
                    }}],
            }
        ]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
</script>
</html>
